#include "iostream"
#include "vector"

using namespace std;

class MinStack {
private:
    vector<int> t;
    int min;
public:
    MinStack() {
        min = INT_MAX;
    }

    void push(int val) {
        if (val < min)min = val;
        t.push_back(val);
    }

    void pop() {
        t.pop_back();
        min = INT_MAX;
        for (auto i: t) {
            if (i < min)min = i;
        }
    }

    int top() {
        return t[t.size() - 1];
    }

    int getMin() {
        return min;
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(val);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */